package cn.cdqf.coupon.dispatch.controller;

import cn.cdqf.coupon.dispatch.service.DispatchService;
import cn.cdqf.global.common.ResultResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api("优惠券派发接口")
public class DispatchController {
    @Autowired
    private DispatchService dispatchService;

    @PutMapping("dispatch/{merchantId}/{userId}/{level}")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "merchantId",type = "path",dataType = "string",required = true),
            @ApiImplicitParam(value = "userId",type = "path",dataType = "string",required = true),
            @ApiImplicitParam(value = "level",type = "path",dataType = "int",required = true)
    })
    @ApiOperation("根据用户id,商户id,等级派发接口")
    public ResultResponse dispatch(
            @PathVariable("merchantId") String merchantId,
            @PathVariable("userId") String userId,
            @PathVariable("level") Integer level
    ){
        dispatchService.dispatchByUserIdAndMerantchIdAndLevel(merchantId,userId,level);
        return  ResultResponse.success();
    }

}
